s=input("Введите строку:")
s1=""
fl = 0
for i in s:
    if i == '(' or i=='[' or i=='{' or i=='<':
        s1+=i
    if i==')':
        if s1[-1]=="(":
            s1=s1[:-1]
        else:
            fl=-1
            break
    if i==']':
        if s1[-1]=="[":
            s1=s1[:-1]
        else:
            fl=-1
            break
    if i=='}':
        if s1[-1]=="{":
            s1=s1[:-1]
        else:
            fl=-1
            break
    if i=='>':
        if s1[-1]=="<":
            s1=s1[:-1]
        else:
            fl=-1
            break
if len(s1)==0 and fl==0:
    print("True")
else:
    print("False")